{% extends "base.html" %}
{% block content %}
<head>
    <title>User</title>
    {{ date_form.media }}
    {{ css_media.media }}
</head>
    <body>
    
    <h3>
        <p> Timesheet: {{ first_name }} {{ last_name }} </p>
    </h3>
    
    {% if is_financier %}
        <a class="link" href="{% url financier %}"> Page of the financier </a>
    {% endif %}
    <br>
    {% if is_manager %}
        <a class="link" href="{% url manager %}"> Page of the manager </a>
    {% endif %}
    
    <p><a class="link" href="{% url user_complete %}"> Completion of data </a></p>
    
    <div align=center>
        <p></p>
        <form method=get>
            <input type=submit name="left" value=left id="date" />
            {{ day.day }}
            <input type=submit name="right" value=right id="date" />
        </form>
        
         {% if times %}
        <form action="" method=post>
        <table class="TableText">
            <tr>
                <th>Project</th>
                <th>Activity</th>
                <th>Hours</th>
                <th>Details</th>
            </tr>
                {% for time in times %}
                    <tr>
                        <td> <input type=text name="project" value="{{ time.0 }}" id="FormComplete" class="UserForm"
                                              onKeydown="javascript:if(13==event.keyCode){return false;}" readonly /> </td>
                        <td> <input type=text name="activity" value="{{ time.1 }}" id="FormComplete" class="UserForm"
                                              onKeydown="javascript:if(13==event.keyCode){return false;}" readonly /> </td>
                        {% if not time.5 %}
                            <td> <input type=text name="time {{ time.4 }}" value="{{ time.2 }}" class="UserForm"
                                                  onKeydown="javascript:if(13==event.keyCode){return false;}" size=3 /> </td>
                            <td> <input type=text name="details {{ time.4 }}" value="{{ time.3 }}" class="UserForm"
                                                  onKeydown="javascript:if(13==event.keyCode){return false;}" size=70 /> </td>
                            <td> <input type=submit value=Delete name="delete {{ time.4 }}" /> </td>
                        {% else %}
                            <td> <input type=text name="time {{ time.4 }}" value="{{ time.2 }}" id="FormComplete" class="UserForm"
                                                  onKeydown="javascript:if(13==event.keyCode){return false;}" size=3 readonly /> </td>
                            <td> <input type=text name="details {{ time.4 }}" value="{{ time.3 }}" id="FormComplete" class="UserForm"
                                                  onKeydown="javascript:if(13==event.keyCode){return false;}" size=70 readonly /> </td>
                        {% endif %}
                {% endfor %}
                    </tr>
                    
                    <tr> 
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
        </table>
                        <input type=submit name="save_form" value="Save" /> 
        </form>
        
        {% endif %}
        
        <p></p>
        <p></p>
        
        <form action="" method=post class="FormTimeCreate">
        
            Projects {{ projects_form.projects }}
            Activities {{ activity_form.activities }}
            Hours {{ time_form.time }}
            Details {{ time_form.details }}
            Date {{ date_form.date }}
            <input type=submit value=Ok id="TimeForm" />

            {% if projects_form.errors %}
                <ul> Projects: {{ projects_form.projects.errors }} </ul>
            {% endif %}
            
            {% if activity_form.errors %}
                <ul> Activities: {{ activity_form.activities.errors }} </ul>
            {% endif %}
            
            {% if time_form.errors %}
                <ul> Hours: {{ time_form.time.errors }} </ul>
            {% endif %}

            {% if date_form.errors %}
                <ul> Date: {{ date_form.date.errors }} </ul>
            {% endif %}

            
        </form>
        
    </div>
    
    <br>
    
    <div class="link">
        <p><a id="logout" href="{% url auth_logout %}">Logout</a>.</p>
    </div>
    </body>
{% endblock %}